<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>组件参数效验与非Props特性</title>
  <script src="../asset/js/vue.js"></script>
</head>

<body>
  <div id="root">
    <child content='hello world'></child>
  </div>
  <script>
    Vue.component('child', {
      props: {
        content: {
          type: [Number, String],
          // required: false, //非必传
          // default: 'default value' //没传值时的默认值
          validator: function (value) {
            // 进行校验,传进来的值的长度必须大于5
            return (value.length > 5)
          }
        }
      },
      template: `<div>{{content}}</div>`
    })
    let vm = new Vue({
      el: '#root'
    })
  </script>
</body>

</html>